<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jquery.js"></script>
</head>
<body>
    <button class="btnToken">点击发送带有token 的请求</button>

<script>
    $(function(){
        let login = async ()=>{
            let {token} = await $.ajax({
                url:'http://localhost:8080/login',
                type:'post',
                data:{
                    uname:'admin',
                    pwd:'123456'
                }
            })
            localStorage.setItem('token',token)
        }

        $('.btnToken').on('click',function(){
            let token = localStorage.getItem('token')
            $.ajax({
                url:'http://localhost:8080/api/home',
                type:'post',
                data:{
                    Authorization:token
                }
            })
        })
    })
</script>
</body>
</html>